<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title><?$page_title?></title>
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"/>
    <link rel="stylesheet" href="/lib/bootstrap/bootstrap.min.css">
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/lib/element-plus/theme-chalk/index.css">
    <script src="/lib/jquery/jquery.min.js"></script>
    <script src="/lib/axios/axios.min.js"></script>
    <script src="/lib/sa0/sa0.js"></script>
</head>
<style>
    body {
        background: #393D49;
    }

    .login-button-wrapper {
        width: 100px;
        height: 50px;
        line-height: 50px;
        background: #393D49;
    }

    .login-input-wrapper {
        width: 500px;
        height: 50px;
    }

    .account, .password {
        font-size: 20px;
    }

    .login-bg-wrapper {
        position: fixed;
        z-index: -1;
        top: 0;
        right: 100px;
        bottom: 0;
        left: 0;
        border-radius: 0 0 999px 0;
        background: #ffffff;
    }

    a {
        text-decoration: none !important;
    }
</style>
<body>
<div class="layui-main layui-box">
    <div class="login-main-wrapper p-5">
        <div class="mt-5">
            <h1><?$admin_title?></h1>
        </div>
        <div class="mt-4">账号</div>
        <div class="mt-2 login-input-wrapper">
            <input type="text" class="layui-input account h-100">
        </div>
        <div class="mt-2">密码</div>
        <div class="mt-2 login-input-wrapper">
            <input type="password" class="layui-input password h-100">
        </div>
        <div class="mt-4">
            <a onclick="loginButtonClick()" class="layui-btn login-button-wrapper">登录</a>
        </div>
        <div class="mt-3 text-muted">
            <span>sa0ChunLuyu</span>
            <span>sa0Admin</span>
        </div>
    </div>
    <div class="login-bg-wrapper"></div>
</div>
</body>
<script src="/lib/vue/vue.global.js"></script>
<script src="/lib/element-plus/index.full.js"></script>
<script src="/lib/layui/layui.all.js"></script>
<script>
    let login_do = false;
    sa0.cookie.del('AdminToken');

    function loginButtonClick() {
        if (login_do) return;
        login_do = true;
        let account = $('.account').val();
        let password = $('.password').val();
        sa0.post({
            url: "<?ap path='/ajax/login'?>",
            data: {account, password},
            done: () => login_do = false,
            then: (res) => {
                layer.msg('登录成功');
                sa0.cookie.set('AdminToken', res.data.token);
                setTimeout(() => {
                    window.location.href = "<?ap path='/index'?>";
                }, 1500);
            },
            error: (res) => layer.msg(res.message)
        });
    }
</script>
</html>